﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WpfApplication2.ViewModels.Afiliado;
using WpfApplication2.UserControls;
using WpfApplication2.SindicatoWebService;

namespace WpfApplication2.Views.Afiliado
{
    /// <summary>
    /// Interaction logic for EditarAfiliado.xaml
    /// </summary>
    public partial class EditarAfiliado : Page
    {
        private EditarAfiliadoViewModel context
        {
            get
            {
                return (EditarAfiliadoViewModel)DataContext;
            }
        }

        public ModalDialog modalDialog { get; set; }
        public Frame ContainerFrame
        {
            get;
            set;
        }


        public EditarAfiliado(Frame frame, ModalDialog modal, BajaAfiliadoDialog bajaModal, AfiliadoDTO afiliado)
        {
            InitializeComponent();
            DataContext = new EditarAfiliadoViewModel(frame, modal, bajaModal, afiliado);
            ContainerFrame = frame;
            modalDialog = modal;
        }

        private void numerosTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key >= Key.D0 && e.Key <= Key.D9 || e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9 || e.Key == Key.Tab)
                e.Handled = false;
            else
                e.Handled = true;
        }


        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            context.LocalidadesCollection = context.WS.GetLocalidadesByProvId(Convert.ToInt32(context.Provincia.Value));
        }

        private void btnCambiarEmpresa_Click(object sender, RoutedEventArgs e)
        {
            context.NombreEmpresa.Value = null;
            context.Cuit.Value = null;
            context.Empresa = null;
            context.CambiarEmpresaVisibility = Visibility.Visible;
            context.EmpresaActualVisibility = Visibility.Collapsed;
        }
    }
}
